package org.sjs.dreamfly.network
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import com.google.gson.TypeAdapter
import com.google.gson.stream.JsonReader
import com.google.gson.stream.JsonToken
import com.google.gson.stream.JsonWriter
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import org.sjs.dreamfly.model.Actor
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.http.GET
import retrofit2.http.Url


object RetrofitUtil {
    private var client = OkHttpClient.Builder()
        .addInterceptor(HttpLoggingInterceptor()
//            .setLevel(HttpLoggingInterceptor.Level.BODY)
            .setLevel(HttpLoggingInterceptor.Level.BASIC)
        )
        .build()

    private val haokanRetrofit by lazy {
        Retrofit.Builder()
            .baseUrl(ApiConstants.BASE_URL_HAOKAN)
            .client(RetrofitUtil.client)
            .addConverterFactory(GsonConverterFactory.create())
            .build()
    }

    private val toutiaoRetrofit by lazy {
        Retrofit.Builder()
            .baseUrl(ApiConstants.BASE_URL_TOUTIAO)
            .client(RetrofitUtil.client)
            .addConverterFactory(GsonConverterFactory.create())
            .build()
    }

    private val ixiguaRetrofit by lazy {
        Retrofit.Builder()
        Retrofit.Builder()
            .baseUrl(ApiConstants.BASE_URL_IXIGUA)
            .client(RetrofitUtil.client)
            .addConverterFactory(GsonConverterFactory.create())
            .build()
    }

    fun getHaoKanRetrofit(): Retrofit {
        return haokanRetrofit
    }
    fun getTouTiaoRetrofit(): Retrofit {
        return toutiaoRetrofit
    }
    fun getIXiGuaRetrofit(): Retrofit {
        return ixiguaRetrofit
    }
}